package com.tools.mytools.nettest;

import android.util.Log;

import com.tools.common.rest.ApiWrapper;
import com.tools.common.rest.Callback;
import com.tools.common.rest.RetrofitFactory;
import com.tools.mytools.BaseActivity;
import com.tools.mytools.R;

import butterknife.OnClick;

/**
 * Created by joe_wang on 11/3/2017.
 */

public class NetworkTestActivity extends BaseActivity {

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_network;
    }

    @OnClick(R.id.do_network_test)
    public void onClickTest() {
        MyApi api = RetrofitFactory.getInstance().getApi(MyApi.class);
        ApiWrapper.call(api.getUserInfo(), new Callback<GithubUser>() {
            @Override
            public void onSuccess(GithubUser o) {
                Log.d("test", "user -> " + o.login);
            }

            @Override
            public void onFailure(Throwable e) {
                Log.d("test", "error occurred");
                e.printStackTrace();
            }

            @Override
            public void onStart() {
                Log.d("test", "start...");
            }

            @Override
            public void onEnd() {
                Log.d("test", "end");
            }
        });
    }
}
